﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace RAP.Framework.Libary.Utils.Map
{
    /// <summary>
    /// 地图魔卡托投影计算工具对象
    /// </summary>
    public class MapUtils
    {
        /// <summary>
        /// 世界范围
        /// </summary>
        public static RectangleF MAX_EXTENT = new RectangleF( -20037508.34f, -20037508.34f, 20037508.34f, 20037508.34f );

        /// <summary>
        /// 最大缩放级别
        /// </summary>
        public static int MAX_ZOOM = 30;

        /// <summary>
        /// 最小分辨率
        /// </summary>
        public static double MIN_RESOLUTION = 156543.033928;

        /// <summary>
        /// 地图瓦块尺寸
        /// </summary>
        public static int MAP_TIEL_SIZE = 256;

        /// <summary>
        /// 各个缩放级别对应的分辨率
        /// </summary>
        private static IList<double> _resolutions = null;

        /**
		 * 获取分级的分辨率数组
		 * */
        public static IList<double> Resolutions
        {
            get
            {
                if ( _resolutions == null )
                {
                    _resolutions = new List<double>( );
                    var res = MIN_RESOLUTION;
                    for ( var i = 1; i <= MAX_ZOOM; i++ )
                    {
                        res = res / 2;
                        _resolutions.Add( res );
                    }
                }
                return _resolutions;
            }
        }

    }
}
